package cn.ixiaoxin.deepchat.controller;

import cn.ixiaoxin.deepchat.entity.User;
import cn.ixiaoxin.deepchat.service.UserService;
import cn.ixiaoxin.deepchat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    // 注册接口
    @PostMapping("/register")
    public Result<?> register(@RequestBody User user) {
        return userService.register(user);
    }

    // 登录接口
    @PostMapping("/login")
    public Result<?> login(@RequestBody User user) {
        return userService.login(user);
    }

    @GetMapping("/checkLogin")
    public Result<?> checkLogin() {
        return userService.checkLogin();
    }

    @GetMapping("/logout")
    public Result<?> logout() {
        return userService.logout();
    }
}
